import org.junit.Test;

/**
 * @author zhangyi
 * @date 2018/12/27 16:05
 */
public class DemoM {
    @Test
    public void fun(){

    }
    @Test
    public void funn(){
        Long s = System.currentTimeMillis();
        int[] a = new int[]{-3,-1,0,0,0,3,3};
        Solution solution = new Solution();
        int i = solution.removeDuplicates(a);
        System.out.println(i);
        for (int c : a){
            System.out.print(c+" ");
        }
        long l = System.currentTimeMillis();
        System.out.println(l-s);
    }

}
class Solution {
    public int removeDuplicates(int[] nums) {
        int index = 0;
        for(int i=0;i<nums.length;i++){
            if(nums[index] != nums[i]){
                index++;
                nums[index] = nums[i];
            }
        }
        return index+1;
    }
}
//class Solution {
//    public int removeDuplicates(int[] nums) {
//        List<Integer> set = new LinkedList<>();
//        for(int i : nums){
//            if(!set.contains(i)){
//                set.add(i);
//            }
//        }
//        int count = 0;
//        Iterator<Integer> iterator = set.iterator();
//        while (iterator.hasNext()){
//            nums[count++] = iterator.next();
//        }
//        return set.size();
//    }
//
//}